#include <bits/stdc++.h>

#define int long long

using namespace std;

void solve()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int m;
    cin >> m;
    string s1;
    cin >> s1;
    string s2;
    cin >> s2;
    string fronts;
    string last;
    for(int i = 0; i < s2.size(); i ++)
    {
        if(s2[i] == 'V')
        {
            fronts.push_back(s1[i]);
        }   
        else
        {
            last.push_back(s1[i]);
        }
    }
    reverse(fronts.begin(),fronts.end());
    string sp = fronts + s + last;
    cout << sp << endl;
}

signed main()
{
    int t;
    cin >> t;
    while(t --)
    {
        solve();
    }
}